<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<form:form commandName="taskNew" cssClass="form-horizontal" role="form">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">任务名称</label>
        <div class="col-sm-8">
            <input type="text" value="${taskNew.taskName}" class="form-control" readonly>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">任务内容</label>
        <div class="col-sm-8">
            <textarea rows="3" class="form-control" readonly>${taskNew.content}</textarea>
        </div>
    </div>

    <div id="feedContainer">
        <c:forEach items="${list}" var="taskBack">

            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right">议题</label>
                <div class="col-sm-8">
                    <textarea rows="3" name="title" class="form-control" readonly>${taskBack.title}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right">反馈内容</label>
                <div class="col-sm-8">
                    <textarea rows="3" name="content" class="form-control" readonly>${taskBack.content}</textarea>
                </div>
            </div>
            <c:if test="${not empty taskBack.result}">
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">批复信息</label>
                    <div class="col-sm-8">
                        <textarea rows="3" name="content" class="form-control" readonly>${taskBack.result}</textarea>
                    </div>
                </div>
            </c:if>

            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right">反馈附件</label>
                <c:if test="${empty taskBack.file}">
                    <div class="col-sm-3">
                        <input type="text" value="无反馈附件" class="form-control" readonly>
                    </div>
                </c:if>
                <c:if test="${!empty taskBack.file}">
                    <div class="col-sm-2">
                        <input type="button" value="下载" onclick="downDetail('${taskBack.file}')"
                               style="width: 100%; height: 32px;"
                               class="btn-large btn-primary"/>
                    </div>
                </c:if>
            </div>
            <%--<div class="form-group">
                <div class="col-sm-3 col-xs-offset-2">
                    <button class="btn btn-sm btn-primary downloadFile" data-id="${listRecords.file}"
                            style="width: 100%;">
                        下载附件
                    </button>
                </div>
            </div>--%>
        </c:forEach>
    </div>
    <c:if test="${not empty taskSend.score}">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right">是否办结:</label>
            <div class="col-sm-2">
                <select name="type"  class="form-control required" disabled>
                    <option value="3" <c:if test="${taskSend.type == '3'}"></c:if>>办结</option>
                    <option value="4" <c:if test="${taskSend.type == '4'}"></c:if>>未办结</option>
                </select>
            </div>
            <label class="col-sm-1 control-label no-padding-right" >办结评价:</label>
            <div class="col-sm-2">
                <select name="score"  class="form-control required" disabled >
                    <option value="${taskSend.score}">${taskSend.comment}</option>

                </select>
            </div>
            <label class="col-sm-1 control-label no-padding-right" >任务得分:</label>
            <div class="col-sm-2">
                <input type="text" value="${taskSend.score}" class="form-control" readonly>
            </div>
        </div>
    </c:if>
    <%--任务办结评价--%>
    <c:if test="${empty taskSend.score}">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right">是否办结:</label>
            <div class="col-sm-3">
                <select name="type" id="type" class="form-control required">
                    <option value=""></option>
                    <option value="3">办结</option>
                    <option value="4">未办结</option>
                </select>
            </div>
            <label class="col-sm-2 control-label no-padding-right">办结评价:</label>
            <div class="col-sm-3">
                <select name="score" id="score" class="form-control required">
                    <option value=""></option>
                    <option value="100">非常好</option>
                    <option value="60">好</option>
                    <option value="30">一般</option>
                    <option value="0">差</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-2">
                    <%--<input type="button" value="消息转发" class="btn-sm btn-success" />--%>
            </div>
        </div>
    </c:if>
    <input type="hidden" name="sysId" value="${taskSendId}">
    <input type="hidden" name="taskId" value="${taskNew.sysId}">
</form:form>
<script src="<s:url value="/assets/js/chosen.jquery.js"></s:url>"></script>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script src="<s:url value="/assets/js/modal/modal.js"></s:url>"></script>

<script type="text/javascript">
    /*  $("#feedContainer").on("click", ".downloadFile", function () {
          var id = $(this).data("id");
          var url = "/filesUpload/download/" + id;
          window.open(url);
      });*/

    //下载按钮
    function downDetail(id) {
        var url = "/filesUpload/download/" + id;
        window.open(url);
    }

    /**
     * 上传附件
     */
    $("#btn-upload").click(function () {
        var fileval = $("#fileupload").val();
        if (fileval == null || fileval == "") {
            alert("未选择任何文件");
            return;
        }
        // 判断文件大小是否大于10M
        var fileSize = $("#fileupload")[0].files[0].size / 1024 / 1024;
        if (fileSize > 10) {
            alert("上传文件大小不能大于10M");
            return;
        }
        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        $.ajaxFileUpload({
            type: "post",
            fileElementId: "fileupload",
            secureuri: false,
            dataType: 'text',
            url: "/filesUpload/uploadBatch",
            // data:fileinfo,
            async: false,
            success: function (data) {
                var data = JSON.parse(data);
                console.log(data);
                var val = data.data.sysid;
                $("#file").attr("value", val);
                if (data.code === "200") {
                    $('.warning>.title>em').html('上传成功');
                } else {
                    $('.warning>.title>em').html('上传失败');
                }
            },
            error: function (data) {
                alert("附件上传失败 ！！请联系管理员");
            }
        });
    });
</script>
